﻿using MvvmFoundation.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace ServiceOperater.ViewModels
{
    public sealed class ActionTreeNodeViewModel : ObservableObject
    {

        public ActionTreeNodeViewModel(string name)
        {
            this.Name = name;
        }

        #region Props
        // 完整属性参见DAPT项目的service-common.xml文件
        private string name = string.Empty;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (name == value)
                {
                    return;
                }

                name = value;

                // TODO 保存起来！

                RaisePropertyChanged("Name");
            }
        }

        private string sqlId = string.Empty;
        public string SqlId
        {
            get
            {
                return sqlId;
            }
            set
            {
                if (sqlId == value)
                {
                    return;
                }

                sqlId = value;

                // TODO 保存起来！

                RaisePropertyChanged("SqlId");
            }
        }

        private string sqlType = string.Empty;
        public string SqlType
        {
            get
            {
                return sqlType;
            }
            set
            {
                if (sqlType == value)
                {
                    return;
                }

                sqlType = value;

                // TODO 保存起来！

                RaisePropertyChanged("SqlType");
            }
        }

        private string result = string.Empty;
        public string Result
        {
            get
            {
                return result;
            }
            set
            {
                if (result == value)
                {
                    return;
                }

                result = value;

                // TODO 保存起来！

                RaisePropertyChanged("Result");
            }
        }

        private string resultType = string.Empty;
        public string ResultType
        {
            get
            {
                return resultType;
            }
            set
            {
                if (resultType == value)
                {
                    return;
                }

                resultType = value;

                // TODO 保存起来！

                RaisePropertyChanged("ResultType");
            }
        }

        private string parameter = string.Empty;
        public string Parameter
        {
            get
            {
                return parameter;
            }
            set
            {
                if (parameter == value)
                {
                    return;
                }

                parameter = value;

                // TODO 保存起来！

                RaisePropertyChanged("Parameter");
            }
        }

        private bool isPage = false;
        public bool IsPage
        {
            get
            {
                return isPage;
            }
            set
            {
                if (isPage == value)
                {
                    return;
                }

                isPage = value;

                // TODO 保存起来！

                RaisePropertyChanged("IsPage");
            }
        }

        private string handler = string.Empty;
        public string Handler
        {
            get
            {
                return handler;
            }
            set
            {
                if (handler == value)
                {
                    return;
                }

                handler = value;

                // TODO 保存起来！

                RaisePropertyChanged("Handler");
            }
        }

        private string condition = string.Empty;
        public string Condition
        {
            get
            {
                return condition;
            }
            set
            {
                if (condition == value)
                {
                    return;
                }

                condition = value;

                // TODO 保存起来！

                RaisePropertyChanged("Condition");
            }
        }

        private string refenerce = string.Empty;
        public string Ref
        {
            get
            {
                return refenerce;
            }
            set
            {
                if (refenerce == value)
                {
                    return;
                }

                refenerce = value;

                // TODO 保存起来！

                RaisePropertyChanged("Ref");
            }
        }

        // ----
        private bool isExpanded = true;
        public bool IsExpanded
        {
            get
            {
                return isExpanded;
            }
            set
            {
                if (isExpanded == value)
                {
                    return;
                }

                isExpanded = value;

                RaisePropertyChanged("IsExpanded");
            }
        }

        private bool isSelected = false;
        public bool IsSelected
        {
            get
            {
                return isSelected;
            }
            set
            {
                if (isSelected == value)
                {
                    return;
                }

                isSelected = value;

                RaisePropertyChanged("IsSelected");
            }
        }

        #endregion

        #region Commands

        public RelayCommand<Object> QueryCommand { get; private set; }

        #endregion

        #region 枚举数据源
        //public IEnumerable<ValueDescription> QXDMList
        //{ get { return EnumHelper.GetAllValuesAndDescriptions<QXDM>(); } }

        //public IEnumerable<ValueDescription> DJLXList
        //{ get { return EnumHelper.GetAllValuesAndDescriptions<DJLX>(); } }
        #endregion
    }
}
